<?php

class SmartHtml
{

/*************************************************************************/
/*************************************************************************/

         function section_part2($section_row,$admin_num,$last_replyicon_num)
    {
                  global $image_path,$DB,$Smarty;

        $getsubsection_query = $DB->sql_query("SELECT * FROM " . $db_prefix . "section WHERE sub_section='1' AND from_sub_section='" . $section_row['id'] . "'");
                  $getsubsection_num   = $DB->sql_num_rows($getsubsection_query);

                  $Smarty->assign_by_ref('section_row',$section_row);
                  $Smarty->assign('last_replyicon_num',$last_replyicon_num);
                  $Smarty->assign('getsubsection_num',$getsubsection_num);

                $getsubsection_rows = array();

                  while ($getsubsection_row = $DB->sql_fetch_array($getsubsection_query))
        {
                           $getsubsection_rows[] = $getsubsection_row;
                           $Smarty->assign('getsubsection_rows',$getsubsection_rows);
                  }

                  $Smarty->assign('admin_num',$admin_num);
                  $Smarty->display('smart-section_part2.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function section_part3($adminmember_row)
    {
                  global $Smarty;

        $Smarty->assign_by_ref('adminmember_row',$adminmember_row);
                  $Smarty->display('smart-section_part3.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function section_part4($num,$num2)
    {
                  global $Smarty;

        $Smarty->assign('num',$num);
                  $Smarty->assign('num2',$num2);
                  $Smarty->display('smart-section_part4.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function section_part5($last_replier,$last_date,$last_subject,$last_subjectid)
    {
                  global $Smarty;

        $Smarty->assign('last_replier',$last_replier);
                  $Smarty->assign('last_date',$last_date);
                  $Smarty->assign('last_subject',$last_subject);
                  $Smarty->assign('last_subjectid',$last_subjectid);
                  $Smarty->display('smart-section_part5.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function section_link($sub=0)
    {
                  global $Smarty,$section_row,$subsection_row;

        if ($sub == 0)
        {
                           $Smarty->assign_by_ref('section_row',$section_row);
                  }
                  else
        {
                           $Smarty->assign_by_ref('section_row',$subsection_row);
                  }

                  $Smarty->display('smart-section_link.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function subject_part($sticksubject_num)
    {
                  global $Smarty;

        $Smarty->assign('sticksubject_num',$sticksubject_num);
                  $Smarty->display('section_subjects1.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function subject_part2($sticksubject_num,$sticksubjects_row)
    {
                  global $Smarty;

        $Smarty->assign('sticksubject_num',$sticksubject_num);
                  $Smarty->assign_by_ref('sticksubjects_row',$sticksubjects_row);
                  $Smarty->display('smart-subject_part2.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function subject_part3()
    {
                  global $Smarty;

        $Smarty->display('section_subjects2.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function subject_part4($subjects_row,$info_row,$member_row,$sharereply_row,$lastsharereply_num,$reply_num)
    {
                  global $image_path;

                  $lastvisit = str_replace('/','',$member_row['lastvisit']);
                  $write_date = str_replace('/','',$subjects_row['write_date']);

                  # We have reply
                  if ($write_date > $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and $lastsharereply_num != 1 and $reply_num != 0 and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_newfolder.gif" border="0" alt="dot newfolder">';
                  }

        if ($write_date == $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and $lastsharereply_num != 1 and $reply_num != 0 and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_folder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date < $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and $lastsharereply_num != 1 and $reply_num != 0 and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_folder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date > $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and ($lastsharereply_num == 1 or $reply_num == 0) and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_folder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date == $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and ($lastsharereply_num == 1 or $reply_num == 0) and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_folder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date < $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and ($lastsharereply_num == 1 or $reply_num == 0) and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_folder.gif" border="0" alt="newfolder">';
                  }

                  # We Don't have reply
                  if ($write_date > $lastvisit and ($subjects_row['writer'] != $_COOKIE['MySBB_username'] and $sharereply_row != 1) and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/newfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date == $lastvisit and ($subjects_row['writer'] != $_COOKIE['MySBB_username'] and $sharereply_row != 1) and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/folder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date < $lastvisit and ($subjects_row['writer'] != $_COOKIE['MySBB_username'] and $sharereply_row != 1) and $subjects_row['close'] != 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/folder.gif" border="0" alt="newfolder">';
                  }

                  # We have reply , and close subject
                  if ($write_date > $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and $lastsharereply_num != 1 and $reply_num != 0 and $subjects_row['close'] == 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_newlockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date == $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and $lastsharereply_num != 1 and $reply_num != 0 and $subjects_row['close'] == 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_lockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date < $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and $lastsharereply_num != 1 and $reply_num != 0 and $subjects_row['close'] == 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_lockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date > $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and ($lastsharereply_num == 1 or $reply_num == 0) and $subjects_row['close'] == 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_lockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date == $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and ($lastsharereply_num == 1 or $reply_num == 0) and $subjects_row['close'] == 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_lockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date < $lastvisit and ($subjects_row['writer'] == $_COOKIE['MySBB_username'] or $sharereply_row == 1) and ($lastsharereply_num == 1 or $reply_num == 0) and $subjects_row['close'] == 1)
        {
                           echo '<img src="' . $image_path . '/statusforum/dot_lockfolder.gif" border="0" alt="newfolder">';
                  }

                  # We Don't have reply , and close subject
                  if ($write_date > $lastvisit and ($subjects_row['writer'] != $_COOKIE['MySBB_username'] and $sharereply_row != 1) and $subjects_row['close'] == 1)
                  {
                           echo '<img src="' . $image_path . '/statusforum/newlockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date == $lastvisit and ($subjects_row['writer'] != $_COOKIE['MySBB_username'] and $sharereply_row != 1) and $subjects_row['close'] == 1)
                  {
                           echo '<img src="' . $image_path . '/statusforum/lockfolder.gif" border="0" alt="newfolder">';
                  }

                  if ($write_date < $lastvisit and ($subjects_row['writer'] != $_COOKIE['MySBB_username'] and $sharereply_row != 1) and $subjects_row['close'] == 1)
                  {
                          echo '<img src="' . $image_path . '/statusforum/lockfolder.gif" border="0" alt="newfolder">';
                  }
         }

/*************************************************************************/
/*************************************************************************/

         function subject_part4_2($subjects_row,$info_row,$member_row,$url_password)
    {
                  global $Smarty;

                  $Smarty->assign_by_ref('subjects_row',$subjects_row);
                  $Smarty->assign_by_ref('info_row',$info_row);
                  $Smarty->assign_by_ref('member_row',$member_row);
                  $Smarty->assign('url_password',htmlspecialchars($url_password));

                  if ($subjects_row['reply_number'] > $info_row['subject_perpage'])
        {
                           $s_page  = -1;
                           $s_start = -1;

                           $RP = new Pager($page);
                           $RP->addtext = 1;

                           $RP->SetPagerN($info_row['subject_perpage'],$subjects_row['reply_number']);

                           $result = $RP->PageNums('main=1&id=' . $subjects_row['id'] . '','','show.php');

                           $Smarty->assign('s_print_page',$result);
                  }

                  $Smarty->display('section_subjects3.tpl');
         }

/*************************************************************************/
/*************************************************************************/


         function subject_part5($subjects_row,$lastreply_row,$lastreply_num)
         {
                  global $Smarty,$info_row;


		if($subjects_row['reply_number'] == 0){
		$last_reply_number_page = 1;
		$start = 0;
		}else{
		$last_reply_number_page = ceil($subjects_row['reply_number']/$info_row[subject_perpage]);
		$start = $info_row[subject_perpage]*($last_reply_number_page-1);
		}

		$Smarty->assign('last_reply_number_page',$last_reply_number_page);
		$Smarty->assign('start_no',$start);
		$Smarty->assign_by_ref('lastreply_row',$lastreply_row);


                  $Smarty->assign_by_ref('subjects_row',$subjects_row);
                  $Smarty->assign_by_ref('lastreply_row',$lastreply_row);
                  $Smarty->assign('lastreply_num',$lastreply_num);
                  $Smarty->display('section_subjects4.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function reply_part2($replier_row,$reply_row,$replier_status,$replier_gender,$text,$mode_toolbar,$w_is_visitor,$getattach_num,$getattach_row)
    {
                  global $SF,$info_row,$DB,$i,$id,$start,$page,$reply_url,$writer_style,$section_row,$topic_time,$Smarty;

                  $user_sig = $replier_row['user_sig'];
                  $user_sig = str_replace('>', '&gt;', $user_sig);
                  $user_sig = str_replace('<', '&lt;', $user_sig);
                  $user_sig = $SF->SmartCode_replace($user_sig);

                   $user_sig = $SF->SmilesReplace($user_sig);

                  $away = $replier_row['away_msg'];
                  $away = str_replace('>', '&gt;', $away);
                  $away = str_replace('<', '&lt;', $away);
                  $away = $SF->SmartCode_replace($away);

                   $away = $SF->SmilesReplace($away);

                  if (empty($reply_row['title']))
        {
                $title = '';
        }
                  else
        {
                $title = htmlspecialchars(stripcslashes($reply_row['title']));
        }

                  $Smarty->assign_by_ref('replier_row',$replier_row);
                  $Smarty->assign_by_ref('info_row',$info_row);
                  $Smarty->assign_by_ref('section_row',$section_row);
                  $Smarty->assign_by_ref('reply_row',$reply_row);
                  $Smarty->assign_by_ref('mode_toolbar',$mode_toolbar);
                  if (!empty($getattach_row))
                  {
                          $Smarty->assign_by_ref('getattach_row',$getattach_row);
                  }

                  $Smarty->assign('topic_time',$topic_time);
                  $Smarty->assign('i',$i);
                  $Smarty->assign('title',$title);
                  $Smarty->assign('reply_url',$reply_url);
                  $Smarty->assign('writer_is_visitor',$w_is_visitor);
                  $Smarty->assign('writer_style',$writer_style);
                  $Smarty->assign('register_date',$SF->DateFormatDo($replier_row['register_date']));
                  $Smarty->assign('replier_status',$replier_status);
                  $Smarty->assign('replier_gender',$replier_gender);
                  $Smarty->assign('text',stripcslashes($text));
                  $Smarty->assign('getattach_num',$getattach_num);
                  $Smarty->assign('user_sig',$user_sig);
                  $Smarty->assign('away',$away);
                  $Smarty->assign('subject_id',intval($_GET['id']));

                  $Smarty->display('smart-reply_part2.tpl');
         }

/*************************************************************************/
/*************************************************************************/

         function subsection_part1()
    {
                  global $Smarty;

        $Smarty->display('section_subsections.tpl');
         }

/*************************************************************************/
/*************************************************************************/

}

?>